package com.eastdigit.bpm.listener;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.runtime.ProcessInstance;

import com.eastdigit.bpm.service.FormFactory;

public class ExecutionTestListener implements ExecutionListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4701916103677935158L;

	@Override
	public void notify(DelegateExecution execution) throws Exception {
		String processInstanceId = execution.getProcessInstanceId();
		ProcessInstance processInstance = execution.getEngineServices()
				.getRuntimeService().createProcessInstanceQuery()
				.processInstanceId(processInstanceId).singleResult();
		String businessKey = processInstance.getBusinessKey();
		//String businessId = FormFactory.getBusinessId(businessKey);
		FormFactory.getFormData(businessKey);
		
		// TODO
		// do somethings by businessId

	}

}
